<extend name="Index/index" />
<block name="nav"></block>
<block name="nav1">
    <div class="page-content">
        <div class="page-header">
            <h1>
                分类管理
                <small>
                    <i class="icon-double-angle-right"></i>
                     查看
                </small>
            </h1>
        </div><!-- /.page-header -->
    </div>
</block>
<block name="admin">
    <div class="pull-left col-md-12">
        <h1 class="text-center">分类管理</h1>
        <hr>
        <div class="col-md-offset-1"><a class="btn-sm btn-info" id="top" style="cursor:pointer;">添加顶级分类</a></div>
        <table class="table h4 mt30">
            <tr class="blue">
                <th>ID</th>
                <th>cname</th>
                <th>父类</th>
                <th>pid</th>
                <th>path</th>
                <th>display</th>
                <th>操作
                    <a href="<{:U('Category/index', array('id'=>$v['pid']))}>" class="btn-sm btn-warning">返回</a>
                </th>
            </tr>
            <empty name="list">
                <tr>
                    <td class="text-center red h1" colspan="7">暂无数据</td>
                </tr>
            <else />
                <volist name="list" id="v">
                    <tr>
                        <td><{$v['id']}></td>
                        <td><{$v['cname']}></td>
                        <td><if condition="$v['pid'] eq '0'">无父类<else /><{$pname}></if></td>
                        <td><{$v['pid']}></td>
                        <td><{$v['path']}></td>
                        <td>
                            <if condition="$v['display'] eq 1"><a href="<{:U('Category/status', array('display'=>$v['display'], 'id'=>$v['id']))}>" class="btn-sm btn-success">显示</a><else /><a href="<{:U('Category/status', array('display'=>$v['display'], 'id'=>$v['id']))}>" class="btn-sm btn-warning">禁用</a></if>
                        </td>
                        <td>
                            <a href="<{:U('Category/index', array('pid'=>$v['id']))}>" class="btn-sm btn-info">查看子类</a>
                            <a class="btn-sm btn-info" onclick="add(this)" style="cursor:pointer;">添加子类</a>
                            <a id="edit" class="btn-sm btn-success" onclick="edit(this, <{$v['id']}>)" style="cursor:pointer;">编辑子类</a>
                            <a href="<{:U('Category/del', array('id'=>$v['id'], 'pid'=>$v['pid']))}>" class="btn-sm btn-danger">删除子类</a>
                        </td>
                    </tr>
                </volist>
            </empty>
        </table>
    </div>

    <!-- 添加顶级分类模态框 -->
    <div id="addTop">
        <div id="topForm">
            <div class="close"><a id="close" class="btn-sm btn-default">X</a></div>
            <div class="text-center">
                <form action="<{:U('Category/add')}>" method="post">
                    <h1 class="text-center">添加顶级分类</h1><br>
                    顶级类名: <input type="text" name="cname"><br><br>
                    pid: &nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="pid" value="0" readonly><br><br>
                    path: &nbsp;&nbsp;<input type="text" name="path" value="0," readonly><br><br>
                    <button class="btn-sm btn-warning">确认添加</button>
                </form>
            </div>
        </div>
    </div>

    <!-- 添加模态框 -->
    <div id="addCate">
        <div id="addForm">
            <div class="close"><a id="addClose" class="btn-sm btn-default">X</a></div>
            <div class="text-center">
                <form action="<{:U('Category/add')}>" method="post">
                    <h1 class="text-center">添加子类</h1><br>
                    子类名: <input type="text" name="cname"><br><br>
                    pid: &nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="pid" readonly><br><br>
                    path: &nbsp;&nbsp;<input type="text" name="path" readonly><br><br>
                    <button class="btn-sm btn-warning">确认添加</button>
                </form>
            </div>
        </div>
    </div>

    <!-- 编辑模态框 -->
    <div id="editCate">
        <div id="editForm">
            <div class="close"><a id="editClose" class="btn-sm btn-default">X</a></div>
            <div class="text-center">
                <form action="<{:U('Category/edit')}>" method="post">
                    <h1 class="text-center">编辑子类</h1><br>
                    <input type="hidden" name="id">
                    子类名: <input type="text" name="cname"><br><br>
                    pid: &nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="pid" readonly><br><br>
                    path: &nbsp;&nbsp;<input type="text" name="path" readonly><br><br>
                    <button class="btn-sm btn-warning">编辑添加</button>
                </form>
            </div>
        </div>
    </div>
</block>
